<?php
namespace plugins\appmarket\controller;

use think\Db;
use think\Controller;
use cmf\controller\PluginRestBaseController;//引用插件基类

/**
*应用市场接口控制器
*/
class ApiIndexController extends PluginRestBaseController
{
	
	/**
	*微信支付回调
	* ['out_trade_no'=>$result['out_trade_no'],'transaction_id'=>$result['transaction_id'],'type'=>$orderinfo['type']];
	*/
	public function wechat_notify($out_trade_no,$transaction_id,$type )
	{
		$find = Db::name( 'module_purchase_history' )->where( 'order_num' , $out_trade_no )->find();
		if( !$find ){
			return zy_array( false , '订单记录不存在！' );
		}
		//修改订单状态
		$res = Db::name( 'module_purchase_history' )->where( 'order_num' , $out_trade_no )->update( [ 'status' => 1 , 'transaction_id' => $transaction_id ] );
		return zy_array( true, '操作成功！'  );
		
	}
	
	public function test ()
	{
		return $this->wechat_notify( 21,21,1);
	}
	
}